import sys
from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QPushButton, QMainWindow
from PyQt5.QtCore import pyqtSignal, QObject


class ChildWindow(QWidget):
    value_changed = pyqtSignal(int)  # 定义一个信号，这里假设传递一个整数类型的值

    def __init__(self):
        super().__init__()
        layout = QVBoxLayout()
        button = QPushButton('Send Value')
        button.clicked.connect(self.send_value)
        layout.addWidget(button)
        self.setLayout(layout)

    def send_value(self):
        value = 42  # 这里假设要传递的值是42
        self.value_changed.emit(value)


class ParentWindow(QMainWindow):

    def __init__(self):
        super().__init__()
        self.child = ChildWindow()
        self.child.value_changed.connect(self.receive_value)
        self.setCentralWidget(self.child)

    def receive_value(self, value):
        print(f"Received value from child: {value}")


if __name__ == '__main__':
    app = QApplication(sys.argv)
    window = ParentWindow()
    window.show()
    sys.exit(app.exec_())
